#include "StdAfx.h"
#include "Debug.h"

void Alert(const char* msg, const char* file, int line)
{
	FormatBuffer<8192> string; //Need a large buffer, doesn't matter about the memory size if we hit this we're erroring anyway
	int result;
	const char* info = "Click ABORT to exit, RETRY to debug, IGNORE to continue\n";
	if (0 != file)
	{
		string.Print("%s(%d):\n\n%s\n\n%s\n", file, line, msg, info);
	}
	else
	{	
		string.Print("%s\n\n%s\n", msg, info);
	}

	//Make sure the cursor shows
	int showCount = 1;
	while (::ShowCursor(true) < 0)
	{
		showCount++;
	}
	result = ::MessageBox(0, string, "Alert!", MB_ABORTRETRYIGNORE|MB_ICONWARNING);
	for (int i = 0; i < showCount; i++)
	{
		::ShowCursor(false);
	}


	if (result == IDABORT)
	{
		exit(1);
	}

	if (result == IDRETRY)
	{
		__debugbreak();
	}
}
